Skip to content

Conversation

@januszjah
Copy link
Contributor

@januszjah januszjah commented Nov 17, 2025

This PR improves constant expression folding for pitch and width parameters in Intel GPU block I/O operations. The changes introduce a more robust constant evaluation mechanism that handles multiple levels of type casts and operation folding, addressing issue #5338.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR improves constant expression folding for pitch and width parameters in Intel GPU block I/O operations. The changes introduce a more robust constant evaluation mechanism that handles multiple levels of type casts and operation folding, addressing issue #5338.

  • Adds a new tryConstEval function that recursively evaluates constants through casts and foldable operations
  • Replaces the previous skipTrunc-based pitch validation with the new evaluation approach
  • Adds width validation using the same constant evaluation mechanism
  • Updates test kernel to mark stride parameters as constexpr to enable better compile-time evaluation

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
third_party/intel/lib/TritonIntelGPUToLLVM/LoadStoreOpToLLVM.cpp Implements new constant evaluation helpers and applies them to pitch/width validation in block I/O conversion
python/test/unit/language/test_block_pointer.py Marks stride parameters as constexpr in test kernel to support improved constant folding

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 54 to 56
if (succeeded(def->fold(results)) && results.size() == 1) {
if (auto val = dyn_cast_or_null<Value>(results[0]))
return val;
}
Copy link

Copilot AI Nov 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The fold result could be an Attribute containing a constant value, not just a Value. If results[0] is an Attribute, it should be converted to a constant Value rather than being ignored. This would cause tryConstEval to miss foldable constant attributes.

Copilot uses AI. Check for mistakes.
@etiotto etiotto linked an issue Nov 17, 2025 that may be closed by this pull request
@januszjah januszjah force-pushed the dev/januszja/5338 branch 2 times, most recently from 6e73ab6 to 06cce6f Compare November 24, 2025 09:59
if (results.empty()) {
if (failed(op->fold(results)))
return std::nullopt;
if (results.empty()) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we keep the comment which explain why we want to fold again?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good catch, thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[2Dblock] fix minicore test's runtime checks

4 participants